<template>
    <div>
        <c-header left-text="返回" title="我的反馈"></c-header>
        <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
            <van-cell v-for="item in list" :key="item.id" :title="item.title" :value="item.content" :label="item.dealStatus===0?'未解决':'已解决'" />
        </van-list>
    </div>
</template>

<script>
import api from "../../api";
export default {
    name: "feedback",
    data() {
        return {
            pageInfo: {
                currentPage: 1,
                pageSize: 10,
                total: 0,
            },
            userId: "",
            list: [],
            loading: false,
            finished: false,
        };
    },
    mounted() {
        this.userId = JSON.parse(localStorage.getItem("userInfo")).id;
        this.getFeedback();
    },
    methods: {
        async getFeedback() {
            this.loading = true;
            const response = await api.notice.getFeedbackPage({
                userId: this.userId,
                ...this.pageInfo,
            });
            this.pageInfo.total = response.data.data.total;
            this.list = response.data.data.records;
            this.loading = false;
        },
        onLoad() {
            this.pageInfo.pageSize += 10;
            this.getFeedback();
            // 数据全部加载完成
            if (this.list.length >= this.pageInfo.total) {
                this.finished = true;
            }
        },
    },
};
</script>

<style lang='less' scoped>
</style>